package com.nisum.mocksimulator.webservice.beans;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
@Qualifier("4x4")
public class Car4x4Type extends CarType implements Externalizable {
	
	public static enum HillAltitudeClimb { NONE, LOW, MEDIUM, HIGH }
	public static enum HillAngleClimb { NONE, _15DEG, _30DEG , _45DEG }

	private HillAltitudeClimb altClimb = HillAltitudeClimb.NONE;
	private HillAngleClimb angleClimb = HillAngleClimb.NONE;
	
	public Car4x4Type() {
		this.setName(null);
		this.setYear(-1);
	}
	
	public Car4x4Type(CarType car) {
		this.setName(car.getName());
		this.setYear(car.getYear());
	}

	public Car4x4Type(CarType car, HillAltitudeClimb altClimb, HillAngleClimb angleClimb) {
		this(car);
		this.setAltClimb(altClimb);
		this.setAngleClimb(angleClimb);
	}
	
    public HillAltitudeClimb getAltClimb() {
		return altClimb;
	}
    
	public void setAltClimb(HillAltitudeClimb altClimb) {
		this.altClimb = altClimb;
	}

	public HillAngleClimb getAngleClimb() {
		return angleClimb;
	}

	public void setAngleClimb(HillAngleClimb angleClimb) {
		this.angleClimb = angleClimb;
	}

	@Override
	public void writeExternal(ObjectOutput out) throws IOException {
		out.writeObject(this.getName());
		out.writeInt(this.getYear());
		out.writeObject(this.getAltClimb());
		out.writeObject(this.getAngleClimb());
	}
	
    @Override
	public void readExternal(ObjectInput in) throws IOException,
			ClassNotFoundException {
		this.setName((String) in.readObject());
		this.setYear(in.readInt());
		this.setAltClimb((HillAltitudeClimb) in.readObject());
		this.setAngleClimb((HillAngleClimb) in.readObject());
	}

	@Override
	public String toString() {
		return "Car4x4Type [altClimb=" + altClimb + ", angleClimb="
				+ angleClimb + ", name=" + name + ", year=" + year + "]";
	}
    
    
}
